Early Preview

This is currently very much a preview. Please feel free to try things out, but don't be upset if anything is not yet working. Feedback is welcome over on our GitHub Dicussions page.

class System.​Collections.​Generic.​OrderedDictionary<​TKey, TValue>

Assembly: System.Collections

Inheritance: object → OrderedDictionary

Implemented Interfaces

Represents a collection of key/value pairs that are accessible by the key or index.

Properties

public int
Capacity
Gets the total number of key/value pairs the internal data structure can hold without resizing.
public IEqualityComparer<​TKey>
Comparer
Gets the <see cref="T:System.Collections.Generic.IEqualityComparer`1" /> that is used to determine equality of keys for the dictionary.
public int
Count
Gets the number of elements contained in the <see cref="T:System.Collections.Generic.ICollection`1" /> .
public TValue
Item
public KeyCollection<​TKey, TValue>
Keys
Gets a collection containing the keys in the <see cref="T:System.Collections.Generic.OrderedDictionary`2" /> .
public ValueCollection<​TKey, TValue>
Values
Gets a collection containing the values in the <see cref="T:System.Collections.Generic.OrderedDictionary`2" /> .

Methods

public void
Add​(TKey key, TValue value)
Adds an element with the provided key and value to the <see cref="T:System.Collections.Generic.IDictionary`2" /> .
key The object to use as the key of the element to add.
value The object to use as the value of the element to add.
public void
Clear​()
Removes all items from the <see cref="T:System.Collections.Generic.ICollection`1" /> .
public bool
ContainsKey​(TKey key)
Determines whether the <see cref="T:System.Collections.Generic.IDictionary`2" /> contains an element with the specified key.
Returns <see langword="true" /> if the <see cref="T:System.Collections.Generic.IDictionary`2" /> contains an element with the key; otherwise, <see langword="false" /> .
key The key to locate in the <see cref="T:System.Collections.Generic.IDictionary`2" /> .
public bool
ContainsValue​(TValue value)
Determines whether the <see cref="T:System.Collections.Generic.OrderedDictionary`2" /> contains a specific value.
Returns <see langword="true" /> if the <see cref="T:System.Collections.Generic.OrderedDictionary`2" /> contains an element with the specified value; otherwise, <see langword="false" /> .
value The value to locate in the <see cref="T:System.Collections.Generic.OrderedDictionary`2" /> . The value can be <see langword="null" /> for reference types.
public int
EnsureCapacity​(int capacity)
Ensures that the dictionary can hold up to <paramref name="capacity" /> entries without resizing.
Returns The new capacity of the dictionary.
capacity The desired minimum capacity of the dictionary. The actual capacity provided may be larger.
public KeyValuePair<​TKey, TValue>
GetAt​(int index)
Gets the key/value pair at the specified index.
Returns The element at the specified index.
index The zero-based index of the pair to get.
public Enumerator<​TKey, TValue>
GetEnumerator​()
Returns an enumerator that iterates through the <see cref="T:System.Collections.Generic.OrderedDictionary`2" /> .
Returns A <see cref="T:System.Collections.Generic.OrderedDictionary`2.Enumerator" /> structure for the <see cref="T:System.Collections.Generic.OrderedDictionary`2" /> .
public int
IndexOf​(TKey key)
Determines the index of a specific key in the <see cref="T:System.Collections.Generic.OrderedDictionary`2" /> .
Returns The index of <paramref name="key" /> if found; otherwise, -1.
key The key to locate.
public void
Insert​(int index, TKey key, TValue value)
Inserts an item into the collection at the specified index.
index The zero-based index at which item should be inserted.
key The key to insert.
value The value to insert.
public bool
Remove​(TKey key)
Removes the element with the specified key from the <see cref="T:System.Collections.Generic.IDictionary`2" /> .
Returns <see langword="true" /> if the element is successfully removed; otherwise, <see langword="false" /> . This method also returns <see langword="false" /> if <paramref name="key" /> was not found in the original <see cref="T:System.Collections.Generic.IDictionary`2" /> .
key The key of the element to remove.
public bool
Remove​(TKey key, TValue& value)
public void
RemoveAt​(int index)
Removes the <see cref="T:System.Collections.Generic.IList`1" /> item at the specified index.
index The zero-based index of the item to remove.
public void
SetAt​(int index, TKey key, TValue value)
Sets the key/value pair at the specified index.
index The zero-based index of the element to get or set.
key The key to store at the specified index.
value The value to store at the specified index.
public void
SetAt​(int index, TValue value)
Sets the value for the key at the specified index.
index The zero-based index of the element to get or set.
value The value to store at the specified index.
public void
TrimExcess​()
Sets the capacity of this dictionary to what it would be if it had been originally initialized with all its entries.
public void
TrimExcess​(int capacity)
Sets the capacity of this dictionary to hold up a specified number of entries without resizing.
capacity The desired capacity to which to shrink the dictionary.
public bool
TryAdd​(TKey key, TValue value)
Adds the specified key and value to the dictionary if the key doesn't already exist.
Returns <see langword="true" /> if the key didn't exist and the key and value were added to the dictionary; otherwise, <see langword="false" /> .
key The key of the element to add.
value The value of the element to add. The value can be <see langword="null" /> for reference types.
public bool
TryAdd​(TKey key, TValue value, Int32& index)
public bool
TryGetValue​(TKey key, TValue& value)
public bool
TryGetValue​(TKey key, TValue& value, Int32& index)
public bool
Equals​(object obj)
Inherited from object
protected void
Finalize​()
Inherited from object
public int
GetHashCode​()
Inherited from object
public Type
GetType​()
Inherited from object
protected object
MemberwiseClone​()
Inherited from object
public string
ToString​()
Inherited from object